<?php
session_start();
	require_once("../db_connect.php");
	if(!array_key_exists("user_id",$_SESSION)){
		header("Location: ../top.php");
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"></script>
<script type="text/javascript" src="../../js/jquery.corner.js"></script>
<script type="text/javascript">
	$(document).ready(
		function() {
			$("#volunteer").click(function () {
				$("#target").attr({
					action: "./PHP/serch_function/index_search.php?target=volunteer"
				});
			});

			$("#thread").click(function () {
				$("#target").attr({
					action: "./PHP/serch_function/index_search.php?target=threads"
				});
			});

			$('.box').corner();
			$('.box2').corner();
			$('.box3').corner();
			$('.box4').corner();
			<?php
				echo array_key_exists("error",$_SESSION)?"login_error('".htmlspecialchars($_SESSION['error'],ENT_QUOTES,"UTF-8")."');":"";
				unset($_SESSION["error"]);
			?>
	});
	function login_error(error){
		alert(error);
	}
</script>
<link rel="stylesheet"  href="../../css/css.css" type="text/css" />

<title>会員情報表示</title>
</head>
    <body>
	<div id="container">
		<div id="header" class="box4">
			<div id="header_box" >
				<div id="title">
				</div>
				<div id="search_box">
					<a href="#" id="volunteer">ボランティア</a>｜<a href="#" id="thread">掲示板</a>
					<form method="post" action="../search_function/search_display_free.php?target=volunteer" id="target">
						<input type="text"  name="search_word"><br />
						<input type="submit" value="検索する" id="search_button">
					</form>
				</div>
			</div>
		</div>
		<div id="rightnavi" class="box">
		<?php if(empty($_SESSION["user_name"])&&empty($_SESSION["user_id"])){?>
			<h3>ログインフォーム</h3>
			<form method="post" action="./user_function/UserLogin.php">
				ID：　　<input type="text" name="id" size="10"><br />
				PASS：<input type="text" name="pass" size="10"><br />
				<input style="margin:10px 0 0 39px;" type="image" src="../img/login.png" alt="送信ボタン" name="submit" align="middle">
			</form>
			<a  href="./PHP/User_create.php"><img style="margin:-20px 0 0 39px;" src="../img/newuser.png" border="0"></a>
		<?php }else{?>
				<img src="../../img/kaiinlogo.png" id="kaiinlogo" />
				<p>ようこそ<?php echo $_SESSION['nick_name']?>さん！</p>
				<p><a href="user_infomation.php">会員情報表示</a></p>
				<p><a href="user_update.php">会員情報変更</a></p>
				<p><a href="user_display_application.php">申請中ボランティア</a></p>
				<p><a href="user_display_volunteer.php">提供中ボランティア</a></p>
				<p><a href="../volunteer_function/volunteer_information_insert.php">ボランティア作成</a></p>
				<p><a href="logout.php">ログアウト</a></p>
				<br />
		<?php }?>
		<img src="../../img/keizilogo.png" id="keizilogo" />
<ul class="menu_margin">
<div id="thread_title_look">
<?php
	//スレッド項目取得
	$sql = "SELECT t.thread_id,count(thread_name) as thread_count,t.thread_name,max(r.response_date) as response_date,t.thread_id FROM thread AS t LEFT OUTER JOIN response AS r ON t.thread_id = r.thread_id group by t.thread_name order by response_date desc limit 0,5";
	$sth = $db->query($sql);
	if (DB::isError($sth)) {
	  exit($sth->getMessage());
	}
	//スレッド表示
	while ($data = $sth->fetchRow(DB_FETCHMODE_ASSOC)) {
	  echo "<li><a href='../response.php?thread_id=".$data['thread_id']."'>";
	  echo mb_strlen($data['thread_name'])>=9?mb_substr($data['thread_name'],0,9)."...":$data['thread_name'];
	  echo "</a></li>";
	}
?>
				</ul>
		<div id="more"><a href="../thread.php" >もっと見る...</a></div>
	</div>
<div id="main"  class="box3">
<br />
	<h1 align="center">会員情報表示</h1>

	<div align="center">
	<table id="table-07"  >
	<?php
	$user_id = $_SESSION['user_id'];
	$sth = "SELECT position_name,user_id,login_id,family_name,given_name,family_kana,given_kana,nick_name,pref,birth_day,phone_number,gender,email
				   ,group_name,group_kana,information,url,group_id
			FROM user u,position p
			WHERE u.post_id = p.position_id and user_id = ?";
	$data = array($user_id);
	$res =& $db->query($sth,$data);

	if (PEAR::isError($res))			//SQLの実行に失敗すればここでエラー文を出力
	{
		die($res->getMessage());
	}

	$row =& $res->fetchRow(DB_FETCHMODE_ASSOC);

	$id = $row['group_id'];
	$sql = "SELECT group_name FROM `group` where `group_id` = ?";
	$data = array($id);
	$gid =& $db->query($sql,$data);
	$gid =& $gid->fetchRow(DB_FETCHMODE_ASSOC);


	?>

		<b>※個人会員情報</b>
		<tr>
		<th>名前</th><td><?php echo $row['family_name'];?><?php echo $row['given_name'];?></td>
		</tr>
		<tr>
		<th>フリガナ</th><td><?php echo $row['family_kana'];?><?php echo $row['given_kana'];?></td>
		</tr>
		<tr>
		<th>ニックネーム</th><td><?php echo $row['nick_name'];?></td>
		</tr>
		<tr>
		<th>ログインID</th><td><?php echo $row['login_id'];?></td>
		</tr>
		<tr>
		<th>生年月日</th><td><?php echo $row['birth_day'];?></td>
		</tr>
		<tr>
		<th>性別</th><td><?php echo $row['gender'];?></td>
		</tr>
		<tr>
		<th>職業</th><td><?php echo $row['position_name'];?></td>
		</tr>
		<tr>
		<th>都道府県</th><td><?php echo $row['pref'];?></td>
		</tr>
		<tr>
		<th>電話番号</th><td><?php echo $row['phone_number'];?></td>
		</tr>
		<tr>
		<th>メールアドレス</th><td><?php echo $row['email'];?></td>
		</tr>
	</table>
	</div>
	<div align="center">
	<br />
	<table id=table-07 >
		<b>※団体会員情報</b>
		<tr>
		<th>団体名</th><td><?php echo $row['group_name'];?></td>
		</tr>
		<tr>
		<th>フリガナ</th><td><?php echo $row['group_kana'];?></td>
		</tr>
		<tr>
		<th>団体紹介文</th><td><?php echo $row['information'];?></td>
		</tr>
		<tr>
		<th>団体URL</th><td><a href=<?php echo $row['url'];?>><?php echo $row['url'];?></a></td>
		</tr>
		<tr>
		<th>団体分類</th><td><?php echo $gid['group_name'];?></td>
		</tr>
	</table>
	</div>
</div>
<div id="space"></div>
		</div>
    </body>
</html>